package acwing.每日一题;/**
 * @author： li
 * @date： 2022-03-18 21:45
 * @version 1.0
 */
import  java.util.*;
public class 单词处理器 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N,K;
        N = sc.nextInt();
        K = sc.nextInt();
        String[] words = new String[N];
        for(int i=0;i<N;i++)
         words[i] = sc.next();
        System.out.println(Arrays.toString(words));
        int len =K; int  current=0;
        for(int i=0;i<N;i++){
            current+=words[i].length();
            if(current<=len){
                System.out.print(words[i]+" ");
            }else {
                System.out.println(" ");
                System.out.print(words[i]+" ");
                current = words[i].length();
            }
        }
        sc.close();
    }
}
